
//
//  rongzixqViewController.m
//  hainingOASystem
//
//  Created by michael on 2017/12/1.
//  Copyright © 2017年 czd. All rights reserved.
//

#import "rongzixqViewController.h"
#import "rzxqTableViewCell.h"
@interface rongzixqViewController ()

@end

@implementation rongzixqViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _array1 = @[@"申请订单:",@"申请人/机构:",@"申请时间:",@"融资用途:",@"融资金额:",@"项目简要说明:",@"融资年限:",@"可接受利率:",@"合作机构:",@"融资方式:",@"质押或抵押物说明:",@"联系人:",@"职务:",@"固定电话:",@"联系人手机:",@"补充说明:"];
      _array2 = @[@"回复意见:",@"可提供融资金额(万):",@"回复机构:",@"回复时间:",@"回复内容:"];
          _array3 = @[@"评论时间:",@"评论内容:"];
          NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:

[UIColor whiteColor],NSForegroundColorAttributeName, nil];
 
[self.navigationController.navigationBar setTitleTextAttributes:attributes];
 self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
         self.title = @"详情";
    self.view.backgroundColor = [UIColor whiteColor];
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,KScreenHeight-kTopHeight) style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];
[self request];
    // Do any additional setup after loading the view.
}
- (void)request{

        NSString *name = [[NSUserDefaults standardUserDefaults] objectForKey:@"userId"];
                NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:@"password"];


NSString *string = [[NSString alloc]initWithFormat:@"%@%@&password=%@&finaceId=%@",krzxq,name,password,_id];
[httpTool ZBPostNetDataWith:string withDic:nil andSuccess:^(NSDictionary* dictionary){
NSLog(@"%@",dictionary);
if (![dictionary[@"reply"]isEqual:[NSNull null]]) {
    _reply = dictionary[@"reply"];

}
if (![dictionary[@"comment"]isEqual:[NSNull null]]) {
    _comment = dictionary[@"comment"];

}
if (![dictionary[@"finace"]isEqual:[NSNull null]]) {
    _finace = dictionary[@"finace"];

}

[_tableView reloadData];

 }andFailure:^{
            [self.view makeToast:@"服务器错误!"];

 }];

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    switch (section) {
        case 0:
            return 16;
            break;
        case 1:
        if(_reply){
            return 5;
            }else{
                       return 0;
            }
        case 2:
 if(_comment){
            return 2;
            }else{
                       return 0;
            }        default:
            return 1;
            break;
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 3;
}
#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
{

  static NSString *CellIdentifier = @"Cellcz0";

    rzxqTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
        cell=[[rzxqTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.dic = _finace;
    cell.array = _array1;
    cell.number = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
    return cell;



 }

}else if (indexPath.section == 1){

  static NSString *CellIdentifier = @"Cellcz1";

    rzxqTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
        cell=[[rzxqTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.dic = _reply;
    cell.array = _array2;
    cell.number = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
    return cell;



 }else{{

  static NSString *CellIdentifier = @"Cellcz2";

    rzxqTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
        cell=[[rzxqTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.dic = _comment;
    cell.array = _array3;
    cell.number = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
    return cell;



 }

}


}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  if (indexPath.section == 0) {
  if([_array1[indexPath.row]isEqualToString:@"项目简要说明:"]){
        CGFloat titleSize = [OAToolBox sizebyText:_finace[@"b_description"] font:13 minsWidth:120];
        if (titleSize >40) {
    return titleSize;
}else{
    return 40;

}
        }
      else if([_array1[indexPath.row]isEqualToString:@"质押或抵押物说明:"]){
        CGFloat titleSize = [OAToolBox sizebyText:_finace[@"m_description"] font:13 minsWidth:120];
        if (titleSize >40) {
    return titleSize;
}else{
    return 40;

}
        }
    else if([_array1[indexPath.row]isEqualToString:@"补充说明:"]){
        CGFloat titleSize = [OAToolBox sizebyText:_finace[@"s_description"] font:13 minsWidth:120];
        if (titleSize >40) {
    return titleSize;
}else{
    return 40;

}
        }else{
        return 40;
        
      
  }}
   else if (indexPath.section == 1) {
   if([_array2[indexPath.row]isEqualToString:@"补充说明:"]){
        CGFloat titleSize = [OAToolBox sizebyText:_reply[@"content"] font:13 minsWidth:120];
        if (titleSize >40) {
    return titleSize;
}else{
    return 40;

}
}else{
    return 40;

}
}else{
 if([_array3[indexPath.row]isEqualToString:@"评论内容:"]){
        CGFloat titleSize = [OAToolBox sizebyText:_comment[@"content"] font:13 minsWidth:120];
        if (titleSize >40) {
    return titleSize;
}else{
    return 40;

}
}else{
    return 40;

}



}
   
   }
   
  

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end

